package com.resource.loginlogoutmanange.config;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.ibatis.annotations.ConstructorArgs;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;


@Getter
@AllArgsConstructor
public enum LoginTypeEnum {
    COMSUMER(0,"游客"),
    STUDENT(1,"学生"),
        TEACHER(2,"老师"),
    MANAGER(3,"管理员");


    private Integer code;
    private String name;


    public static String parseName(Integer code){
        Optional<String> optional = Arrays.stream(values()).filter(item -> Objects.equals(code, item.getCode())).findFirst()
                .map(item -> item.getName());
        return optional.isPresent() ? optional.get() : null;}

}
